<template>
  <van-sticky>
    <van-nav-bar :title="titleway" left-arrow @click-left="onClickLeft">
      <div class="right" slot="right" @click="hrefs()">
        <van-icon :name="phone" slot="right" />自选
      </div>
    </van-nav-bar>
  </van-sticky>
</template>

<script>
import phone from "./add.png";
import { updateyprice } from "../../api/price";
export default {
  data() {
    return {
      phone
    };
  },
  computed: {
    titleway() {
      return this.$route.query.kname||this.$route.meta.title  ;
    }
  },
  methods: {
    hrefs() {
      let query = {};
      let i = this.$route.query;
      let obj = {};
      obj.channel = i.channel;
      obj.id = i.id;
      obj.op = "add";
      updateyprice(obj).then(res => {
        if (res.code == "0000") {
          this.$store.dispatch("acLoginprice", obj);
          i.menunameflag="all";
          this.$router.push({path: `/pricepart${i.channel}` ,query:i})
        } else {
          this.$toast(res.msg);
        }
      });
    },
    onClickLeft() {
      this.$router.go(-1);
    }
  }
};
</script>

<style lang="less">
.van-nav-bar {
  .van-icon {
    color: #272937;
    font-size: 20px;
  }
  .van-nav-bar__text {
    color: #272937;
  }
  color: #e49829;

  img {
    width: 16px;
  }
  .right {
    display: flex;
    justify-content: center;
    align-items: center;
  }
}
</style>
